<!DOCTYPE html>
<html>

<head>
    <meta name="layout" content="main2"/>
    <g:set var="entityName" value="${message(code: 'lead.label', default: 'lead')}"/>
    <title>线索详情</title>
</head>
<body>
<div class="main-body">
    <div class="page-wrapper">
        <!-- Page-header start -->
        <div class="page-header">
            <div class="page-header-title">
                <h4>线索详情</h4>
            </div>

            <div class="page-header-breadcrumb">
                <ul class="breadcrumb-title">
                    <li class="breadcrumb-item">
                        <a href="/salesDashboard/index">
                            <i class="icofont icofont-home"></i>
                        </a>
                    </li>
                    <li class="breadcrumb-item">
                        <g:link controller="lead" action="index">线索列表</g:link>
                    </li>
                    <li class="breadcrumb-item">线索详情</li>
                </ul>
            </div>
        </div>
        <!-- Page-header end -->
        <!-- Page-body start -->
        <div class="page-body">
            <g:if test="${flash.message}">
                <div class="message alert alert-info" role="status">${flash.message}
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">×</span></button>
                </div>
            </g:if>

        <!-- Hover table card start -->
            <div class="card">
                <div class="card-header">
                    <h5>公司信息</h5>

                    <div class="card-header-right">
                        <!-- <button class="btn btn-success btn-mini" type="button" data-toggle="modal" data-target="#myModal10" id="click"><i class="fa fa-refresh"></i> 转换商机</button> -->
                        <g:link action="changeToOpportunity" id="${this?.lead?.id}" data-toggle="tooltip" data-placement="top" data-original-title="转换商机">
                            <i class="icofont icofont-refresh"></i>
                        </g:link>
                        <g:link action="edit" resource="${this.lead}" data-toggle="tooltip" data-placement="top" data-original-title="编辑">
                            <i class="icofont icofont-edit"></i>
                        </g:link>
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>

                <div class="card-block">
                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">公司名称</label>

                        <div class="col-md-3">
                            <p class="form-control-static">${this.lead?.company}</p>
                        </div>
                        <label class="col-md-2 col-form-label">人数</label>

                        <div class="col-md-3">
                            <p class="form-control-static">${this.lead?.numberOfEmployees}</p>
                        </div>

                    </div>

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">行业</label>

                        <div class="col-md-3">
                            <p class="form-control-static">${this.lead?.industry?.name}</p>
                        </div>

                        <label class="col-md-2 col-form-label">网站</label>

                        <div class="col-md-3">
                            <p class="form-control-static">${this.lead?.website}</p>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">地址</label>

                        <div class="col-md-3">
                            <p class="form-control-static">${this.lead?.address}</p>
                        </div>
                        <label class="col-md-2 col-form-label">所有人</label>

                        <div class="col-md-3">
                            <p class="form-control-static">${this.lead?.user}</p>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">客户</label>

                        <div class="col-md-3">
                            <p class="form-control-static">${this.lead?.account}</p>
                        </div>
                        
                    </div>

                </div>
            </div>
            <!-- Hover table card end -->
            <div class="card">
                <div class="card-header">
                    <h5>状态</h5>

                    <div class="card-header-right">
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>

                <div class="card-block">
                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">评级</label>

                        <div class="col-md-3">
                            <p class="form-control-static">${this.lead?.rating?.name}</p>
                        </div>
                        <label class="col-md-2 col-form-label">状态</label>

                        <div class="col-md-3">
                            <p class="form-control-static">${this.lead?.status?.name}</p>
                        </div>
                    </div>

                </div>

            </div>

            <div class="card">
                <div class="card-header">
                    <h5>线索信息</h5>

                    <div class="card-header-right">
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>

                <div class="card-block">
                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">姓名</label>

                        <div class="col-md-3">
                            <p class="form-control-static">${this.lead?.fullName}</p>
                        </div>
                        <label class="col-md-2 col-form-label">称谓</label>

                        <div class="col-md-3">
                            <p class="form-control-static">${this.lead?.salutation?.name}</p>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">头衔</label>

                        <div class="col-md-3">
                            <p class="form-control-static">${this.lead?.title}</p>
                        </div>
                        <label class="col-md-2 col-form-label">邮件</label>

                        <div class="col-md-3">
                            <p class="form-control-static">${this.lead?.email}</p>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">手机</label>

                        <div class="col-md-3">
                            <p class="form-control-static">${this.lead?.cellphone}</p>
                        </div>
                        <label class="col-md-2 col-form-label">座机</label>

                        <div class="col-md-3">
                            <p class="form-control-static">${this.lead?.phone}</p>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">线索描述</label>
                        <div class="col-md-8">
                            <p class="form-control-static">
                                ${this.lead?.description}
                            </p>
                        </div>
                    </div>

                </div>

            </div>
            <div class="card">
                <div class="card-header">
                    <h5>笔记</h5>

                    <div class="card-header-right">
                        <g:link controller="note" action="create" params="[lead: this.lead?.id]" data-toggle="tooltip" data-placement="top" title="" data-original-title="新增">
                            <i class="icofont icofont-plus"></i>
                        </g:link>
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <g:render template="/layouts/mashTemplate/noteTemplate"/>
            </div>

            <div class="card">
                <div class="card-header">
                    <h5>定制字段</h5>

                    <div class="card-header-right">
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <g:render template="/layouts/mashTemplate/flexFieldInstanceTemplate"/>
            </div>

            <div class="card">
                <div class="card-header">
                    <h5>地址</h5>

                    <div class="card-header-right">
                        <g:link controller="address" action="create" params="[lead: this.lead?.id]"
                                data-toggle="tooltip" data-placement="top" title="" data-original-title="新增">
                            <i class="icofont icofont-plus"></i>
                        </g:link>
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <g:render template="/layouts/mashTemplate/addressTemplate"/>
            </div>


            <div class="card">
                <div class="card-header">
                    <h5>团队</h5>

                    <div class="card-header-right">
                        <g:link controller="leadTeam" action="create"
                                params="[lead: this.lead?.id]" data-toggle="tooltip" data-placement="top"
                                title="" data-original-title="新增">
                            <i class="icofont icofont-plus"></i>
                        </g:link>
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <g:render template="/layouts/mashTemplate/teamTemplate"/>
            </div>

            <div class="card">
                <div class="card-header">
                    <h5>附件</h5>

                    <div class="card-header-right">
                        <g:link controller="attachment" action="create" params="[lead: this.lead?.id]"
                                data-toggle="tooltip" data-placement="top" title="" data-original-title="新增">
                            <i class="icofont icofont-plus"></i>
                        </g:link>
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <g:render template="/layouts/mashTemplate/attachmentTemplate"/>
            </div>

            

        </div>

        <!-- Page-body end -->
    </div>
</div>

<div class="modal fade" id="myModal10" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="color-line"></div>

            <div class="modal-header">
                <h4 class="modal-title">是否转换成商机？</h4>
                <small class="font-bold text-danger">注意：是否转换成商机！</small>
            </div>

            <div class="modal-body">
                <g:form action="changeToOpportunity" class="form-horizontal" name="myForm" method="GET">
                    <input type="hidden" name="enableTerritory" id="enableTerritory" value="${this.enableTerritory}"/>
                    <input type="hidden" name="id" id="id" value="${this.lead.id}"/>

                    <g:if test="${this.enableTerritory}">
                        <div class="form-group row">
                            <label class="col-md-2 col-form-label is-required">销售区域</label>

                            <div class="col-md-3">
                                <g:select class="form-control" name="territoryName" optionKey="name" optionValue="name"
                                          from="${com.next.Territory.findAllByActive(true)}" noSelection="${['': '请选择']}"/>
                            </div>
                        </div>
                    </g:if>
                    <div class="form-group row">
                        <label class="col-md-2 col-form-label is-required">联系人姓名</label>

                        <div class="col-md-3">
                            <g:textField class="form-control" name="contactName" id="contactName"
                                         value="${this.lead?.fullName}"/>
                        </div>

                        <label class="col-md-2 col-form-label is-required">称谓</label>

                        <div class="col-md-3">
                            <g:select class="form-control" name="salutation" id="salutation" optionValue="name"
                                      optionKey="name" from="${com.next.Salutation.list()}" noSelection="${['': '请选择']}"
                                      value="${this.lead?.salutation?.name}"/>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label is-required">手机</label>

                        <div class="col-md-3">
                            <g:textField class="form-control" name="cellphone" id="cellphone"
                                         value="${this.lead?.cellphone}"/>
                        </div>

                        <label class="col-md-2 col-form-label is-required">电话</label>

                        <div class="col-md-3">
                            <g:textField class="form-control" name="phone" id="phone" value="${this.lead?.phone}"/>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label is-required">头衔</label>

                        <div class="col-md-3">
                            <g:textField class="form-control" name="title" id="title" value="${this.lead?.title}"/>
                        </div>

                        <label class="col-md-2 col-form-label is-required">邮箱</label>

                        <div class="col-md-3">
                            <g:field type="email"  class="form-control" name="email" id="email" value="${this.lead?.email}"/>
                        </div>
                    </div>





                    <div class="form-group row">
                        <label class="col-md-2 col-form-label is-required">客户名称</label>

                        <div class="col-md-3">
                            <g:textField class="form-control" name="accountName" id="accountName"
                                         value="${this.lead?.company}"/>
                        </div>
                        <label class="col-md-2 col-form-label is-required">客户类型</label>

                        <div class="col-md-3">
                            <g:select class="form-control" name="accountType"
                                      id="accountType" optionKey="name" optionValue="name"
                                      from="${com.next.AccountType.list()}"
                                      noSelection="${['': '请选择']}"/>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">网站</label>

                        <div class="col-md-3">
                            <g:field type="url" class="form-control" name="website" id="website"
                                         value="${this.lead?.website}"/>
                        </div>

                        <label class="col-md-2 col-form-label">上级客户</label>

                        <div class="col-md-3">
                            <g:select class="form-control" name="parent"
                                      id="parent" optionKey="name" optionValue="name" from="${com.next.Account.findAllByActive(true)}"
                                      noSelection="${['': '请选择']}"/>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">行业</label>

                        <div class="col-md-3">
                            <g:select class="form-control" name="industry" id="industry" optionValue="name"
                                      optionKey="name"
                                      from="${com.next.Industry.list()}" noSelection="${['': '请选择']}"
                                      value="${this.lead?.industry?.name}"/>
                        </div>

                        <label class="col-md-2 col-form-label">雇员数量</label>

                        <div class="col-md-3">
                            <g:field type="number" class="form-control integer" name="numberOfEmployees" id="numberOfEmployees"
                                     value="${this.lead?.numberOfEmployees}"/>
                        </div>
                    </div>

                </g:form>
            </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" id="submit">保存</button>
            </div>
        </div>
    </div>
</div>
<g:javascript>
    $(function () {

        $("#submit").click(function () {

            // 线索
            var id = $("#id").val().trim();

            // 销售区域
            var enableTerritory = $("#enableTerritory").val();
            var territoryName = $("#territoryName").val();
            if (enableTerritory == 'true' && !territoryName) {
                toastr.error('请选择销售区域');
                return;
            }

            // 客户姓名
            var accountName = $("#accountName").val().trim();
            if (!accountName) {
                toastr.error('请输入客户姓名');
                return;
            }

            // 联系人姓名
            var contactName = $("#contactName").val().trim();
            if (!contactName) {
                toastr.error('请输入联系人姓名');
                return;
            }

            $("#myForm").submit();
        });
    });
</g:javascript>
</body>

</html>
